﻿using Engine;
using TemplatesDatabase;

namespace Game
{
    public class heWater : SubsystemBlockBehavior
    {
        public SubsystemAudio m_subsystemAudio;

        public Random m_random = new Random();

        public ComponentHealth componentHealth;

        public ComponentVitalStats componentVitalStats;

        public SubsystemTerrain m_subsystemTerrain;

        public override int[] HandledBlocks => new int[0];

        public override bool OnUse(Ray3 ray, ComponentMiner componentMiner)
        {
            m_subsystemAudio.PlaySound("Audio/喝水", 3f, m_random.Float(-0.1f, 0.1f), ray.Position, 1f, autoDelay: true);
            ComponentPlayer componentPlayer = componentMiner.ComponentPlayer;
            if (componentPlayer != null)
            {
                componentMiner.Entity.FindComponent<ComponentThirst>().Water += 0.8f;
                componentPlayer.ComponentGui.DisplaySmallMessage("你不再感到口渴...", Color.White, blinking: true, playNotificationSound: false);
            }

            componentMiner.RemoveActiveTool(1);
            componentPlayer.ComponentMiner.Inventory.AddSlotItems(componentPlayer.ComponentMiner.Inventory.ActiveSlotIndex, 315, 1);
            return true;
        }

        public override void Load(ValuesDictionary valuesDictionary)
        {
            base.Load(valuesDictionary);
            m_subsystemTerrain = base.Project.FindSubsystem<SubsystemTerrain>(throwOnError: true);
            m_subsystemAudio = base.Project.FindSubsystem<SubsystemAudio>(throwOnError: true);
        }
    }
}